package com.shihb.principle.liskov;

/**
 *Description:里氏替换原则
 *Version:1.0.0
 *@author shihb
 *@date 2020/6/28 21:59
 */
public class Demo {

  public static void main(String[] args) {
    A a = new A();
    System.out.println("11-8="+a.function1(11,8));
    B b= new B();
    // 使用方以为b继承了a,不知道b重写了，本意是要运行A的function1,造成了错误
    System.out.println("11-8="+b.function1(11,8));
  }

}
class  A {
  public  int function1(int a,int b){
    return a-b;
  }
}
class B extends A{
  // B重写了方法一,有可能时无意重写的
  @Override
  public  int function1(int c,int d){
    return c+d;
  }
  public  int function2(int c,int d ){
    return function1(c,d)*2;
  }
}
